
/**
 * @Project : Clion_ProgrammingExercises
 * @File : 2816
 * @Author : WangRuoyu 
 * @Date : 2023/9/17 16:56
 */

#include "iostream"

using namespace std;

int main() {
    int m, n;
    scanf("%d %d", &m, &n);
    int a[m];
    int b[n];
    for (int i = 0; i < m; ++i) {
        scanf("%d", &a[i]);
    }
    for (int i = 0; i < n; ++i) {
        scanf("%d", &b[i]);
    }

    int i = 0;
    for (int j = 0; j < n; ++j) {
        if (a[i] == b[j]) i++;
        if (i == m) {
            printf("Yes");
            return 0;
        }
    }

    printf("No");

    return 0;
}